Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: get tiflash http(s) port from tiflash status port instead of etcd #30901

Merged
merged 8 commits into from
Dec 28, 2021

Conversation

lidezhu
Copy link
Contributor

@lidezhu lidezhu commented Dec 21, 2021

What problem does this PR solve?

Issue Number: close #xxx

Problem Summary: There are two system tables about tiflash in tidb that need to read data from tiflash http(s) port. Previously tidb get http(s) port from etcd which was reported by tiflash. But from v5.3, we can get tiflash config from tiflash status port and so we can parse the http(s) port from the config instead of etcd.

What is changed and how it works?

The system tables' behavior remains the same as in #18092 and #19714.
The only difference is that we get http(s) port from the config fetched from tiflash status port instead of etcd.
The detailed steps are as following:

  1. get tiflash_proxy_status_port for every tiflash instance;
  2. get tiflash config from the url: {tiflash_host}:{tiflash_proxy_status_port}/config;
  3. get tiflash http_port or https_port from the config items engine-store.http_port or engine-store.https_port;

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    deploy a tidb cluster and check we can select from the two tiflash system tables tiflash_segments and tiflash_tables as before.

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Dec 21, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • fzhedu
  • windtalker

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 21, 2021
@lidezhu lidezhu changed the title *: get tiflash http(s) port from config instead of etcd *: get tiflash http(s) port from tiflash status port instead of etcd Dec 21, 2021
@lidezhu
Copy link
Contributor Author

lidezhu commented Dec 21, 2021

/cc @crazycs520 @windtalker PTAL

@sre-bot
Copy link
Contributor

sre-bot commented Dec 21, 2021

@lidezhu
Copy link
Contributor Author

lidezhu commented Dec 22, 2021

/run-unit-test

@ti-chi-bot
Copy link
Member

@CalvinNeo: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 28, 2021
@lidezhu
Copy link
Contributor Author

lidezhu commented Dec 28, 2021

/merge

@ti-chi-bot
Copy link
Member

@lidezhu: /merge is only allowed for the committers, you can assign this pull request to the committer in list by filling /assign @committer in the comment to help merge this pull request.

In response to this:

/merge

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

}
info.ResolveLoopBackAddr()
if len(tiflashInstances) > 0 && !tiflashInstances.Exist(info.Address) {
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

append a warning?

Copy link
Contributor Author

@lidezhu lidezhu Dec 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiflashInstances is just the where clause in the select list.
For example, if the sql is select * from tiflash_tables, then tiflashInstances is empty and it means we need to select the info for all tiflash nodes in the cluster.
If the sql is select * from tiflash_tables where tiflash_instance='127.0.0.1:9000', then tiflashInstances contains the element 127.0.0.1:9000 and we need filter out other tiflash nodes.

Comment on lines +2637 to +2643
if err != nil {
sctx.GetSessionVars().StmtCtx.AppendWarning(err)
continue
}
if resp.StatusCode != http.StatusOK {
return errors.Errorf("request %s failed: %s", configURL, resp.Status)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should append warning or return error first?

Copy link
Contributor Author

@lidezhu lidezhu Dec 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If tiflash doesn't return response, it means the tiflash node is down or is network partitioned, we can safely ignore the tiflash node and just append warning.
But if tiflash can return response, but the status code is not StatusOK, then something bad unknown must happen and an error is perfered to remind this case.

@fzhedu
Copy link
Contributor

fzhedu commented Dec 28, 2021

what if tiflash config has errors of format? like 127...0.0:2222222

@lidezhu
Copy link
Contributor Author

lidezhu commented Dec 28, 2021

what if tiflash config has errors of format? like 127...0.0:2222222

The config read from tiflash status port is already checked by tiflash instance. If the http_port is not a valid value, then tiflash cannot start.

Copy link
Contributor

@fzhedu fzhedu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-chi-bot ti-chi-bot removed the status/LGT1 Indicates that a PR has LGTM 1. label Dec 28, 2021
@ti-chi-bot ti-chi-bot added the status/LGT2 Indicates that a PR has LGTM 2. label Dec 28, 2021
@fzhedu
Copy link
Contributor

fzhedu commented Dec 28, 2021

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: cfbad4e

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Dec 28, 2021
@ti-chi-bot
Copy link
Member

@lidezhu: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@lidezhu
Copy link
Contributor Author

lidezhu commented Dec 28, 2021

/rebuild

@lidezhu
Copy link
Contributor Author

lidezhu commented Dec 28, 2021

/merge

@ti-chi-bot
Copy link
Member

@lidezhu: /merge is only allowed for the committers, you can assign this pull request to the committer in list by filling /assign @committer in the comment to help merge this pull request.

In response to this:

/merge

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot merged commit f35e84c into pingcap:master Dec 28, 2021
@lidezhu lidezhu deleted the improve-tiflash-system-tables branch December 28, 2021 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants